define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
    if(Config.tracking_number == '' || Config.tracking_number == null){
        Config.tracking_number = 0;
    }
    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'fedition_orderopenpx/index/?tracking_number=' + Config.tracking_number,
                    add_url: 'fedition_orderopenpx/add',
                    edit_url: 'fedition_orderopenpx/edit',
                    del_url: 'fedition_orderopenpx/del',
                    multi_url: 'fedition_orderopenpx/multi',
                    import_url: 'fedition_orderopenpx/import',
                    table: 'fedition_orderopenpx',
                }
            });

            var table = $("#table");

            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                pk: 'id',
                sortName: 'occurDatetime',
                columns: [
                    [
                        {checkbox: true},
                        //{field: 'id', title: __('Id')},
                        //{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        //{field: 'updatetime', title: __('Updatetime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
                        //{field: 'status', title: __('Status'), searchList: {"normal":__('Normal'),"hidden":__('Hidden')}, formatter: Table.api.formatter.status},
                        //{field: 'order_id', title: __('Order_id'), operate: 'LIKE'},
                        //{field: 'tracking_company', title: __('物流公司'), operate: 'LIKE'},
                        //{field: 'tracking_number', title: __('物流单'), operate: 'LIKE'},
                        {field: 'country', title: __('Country'), operate: 'LIKE'},
                        //{field: 'businessLinkCode', title: __('Businesslinkcode'), operate: 'LIKE'},
                        {field: 'occurDatetime', title: __('Occurdatetime'), operate: 'LIKE'},
                        {field: 'occurLocation', title: __('Occurlocation'), operate: 'LIKE'},
                        {field: 'trackingContent', title: __('Trackingcontent'), operate: 'LIKE'},
                        //{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
                    ]
                ]
            });

            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            bindevent: function () {
                Form.api.bindevent($("form[role=form]"));
            }
        }
    };
    return Controller;
});